home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ham Radio 2000
/
Ham Radio 2000.iso
/
ham2000
/
tcp_ip
/
ntp_src
/
diff.ntp
next >
Wrap
Text File
|
1992-04-03
|
26KB
|
762 lines
*** /tmp/,RCSt1016606 Tue Jun 25 11:10:51 1991
--- commands.h Tue Jun 25 10:42:12 1991
***************
*** 121,126 ****
--- 121,129 ----
int donetrom __ARGS((int argc,char *argv[],void *p));
int nr_attach __ARGS((int argc,char *argv[],void *p));
+ /* In ntpd.c: */
+ int dontp __ARGS((int argc, char *argv[], void *p));
+
/* In pc.c: */
int doshell __ARGS((int argc,char *argv[],void *p));
int doisat __ARGS((int argc,char *argv[],void *p));
*** /tmp/,RCSt1016611 Tue Jun 25 11:10:53 1991
--- config.c Tue Jun 25 10:42:17 1991
***************
*** 307,312 ****
--- 307,315 ----
#ifdef NRS
"nrstat", donrstat, 0, 0, NULLCHAR,
#endif /* NRS */
+ #ifdef NTP
+ "ntp", dontp, 0, 0, NULLCHAR,
+ #endif /* NTP */
"param", doparam, 0, 2, "param <interface>",
"ping", doping, 512, 2,
"ping <hostid> [<length> [<interval> [incflag]]]",
***************
*** 440,446 ****
--- 443,453 ----
/* Functions to be called on each clock tick */
void (*Cfunc[])() = {
+ #ifdef NTP
+ ntppctick, /* PC and NTP specific stuff to keep time. */
+ #else /* not NTP */
pctick, /* Call PC-specific stuff to keep time */
+ #endif /* not NTP */
kbint, /* Necessary because there's no hardware keyboard interrupt */
refiq, /* Replenish interrupt pool */
#ifdef ASY
*** /tmp/,RCSt1016621 Tue Jun 25 11:10:57 1991
--- internet.tl Tue Jun 25 10:42:21 1991
***************
*** 23,26 ****
+arpcmd.obj &
+arp.obj &
+arphdr.obj &
! +netuser.obj
--- 23,39 ----
+arpcmd.obj &
+arp.obj &
+arphdr.obj &
! +netuser.obj &
! +ntpd.obj &
! +ntp_config.obj &
! +ntp_io.obj &
! +ntp_leap.obj &
! +ntp_loopfilter.obj &
! +ntp_pcclock &
! +ntp_peer.obj &
! +ntp_proto.obj &
! +ntp_restrict.obj &
! +ntp_timer.obj &
! +ntp_util.obj &
! +ntp_control.obj &
! +ntp_version.obj
*** /tmp/,RCSt1016626 Tue Jun 25 11:11:00 1991
--- makefile Tue Jun 25 10:42:25 1991
***************
*** 53,59 ****
ipcmd.obj ip.obj iproute.obj iphdr.obj \
icmpcmd.obj icmp.obj icmpmsg.obj icmphdr.obj \
arpcmd.obj arp.obj arphdr.obj \
! netuser.obj
AX25= ax25cmd.obj ax25user.obj ax25.obj \
axheard.obj lapbtime.obj \
--- 53,62 ----
ipcmd.obj ip.obj iproute.obj iphdr.obj \
icmpcmd.obj icmp.obj icmpmsg.obj icmphdr.obj \
arpcmd.obj arp.obj arphdr.obj \
! netuser.obj \
! ntpd.obj ntp_config.obj ntp_io.obj ntp_leap.obj ntp_loopfilter.obj \
! ntp_pcclock.obj ntp_peer.obj ntp_proto.obj ntp_restrict.obj \
! ntp_timer.obj ntp_util.obj ntp_version.obj ntp_control.obj
AX25= ax25cmd.obj ax25user.obj ax25.obj \
axheard.obj lapbtime.obj \
***************
*** 82,88 ****
pc100vec.obj eaglevec.obj hapnvec.obj \
scc.obj sccvec.obj \
pi.obj pivec.obj \
! pcgen.obj sw.obj stopwatch.obj arcnet.obj
makelist.exe: makelist.obj getopt.obj
$(CC) $(MODEL) makelist.obj getopt.obj
--- 85,92 ----
pc100vec.obj eaglevec.obj hapnvec.obj \
scc.obj sccvec.obj \
pi.obj pivec.obj \
! pcgen.obj sw.obj stopwatch.obj arcnet.obj \
! ntp_pc.obj
makelist.exe: makelist.obj getopt.obj
$(CC) $(MODEL) makelist.obj getopt.obj
***************
*** 241,247 ****
nrhdr.obj: nrhdr.c global.h mbuf.h ax25.h iface.h proc.h timer.h sockaddr.h lapb.h netrom.h nr4.h
nrs.obj: nrs.c global.h mbuf.h iface.h proc.h timer.h pktdrvr.h ax25.h sockaddr.h lapb.h nrs.h asy.h trace.h commands.h
pathname.obj: pathname.c global.h dirutil.h
! pc.obj: pc.c global.h mbuf.h proc.h timer.h iface.h internet.h session.h hardware.h ftpcli.h ftp.h telnet.h socket.h sockaddr.h cmdparse.h pc.h
pc100.obj: pc100.c global.h mbuf.h iface.h proc.h timer.h pktdrvr.h netuser.h pc100.h 8530.h ax25.h sockaddr.h lapb.h trace.h pc.h session.h hardware.h ftpcli.h ftp.h telnet.h
pi.obj: pi.c global.h mbuf.h iface.h proc.h timer.h pktdrvr.h netuser.h pi.h 8530.h ax25.h sockaddr.h lapb.h trace.h pc.h session.h hardware.h ftpcli.h ftp.h telnet.h ip.h internet.h devparam.h
pktdrvr.obj: pktdrvr.c global.h proc.h mbuf.h timer.h netuser.h enet.h iface.h arcnet.h ax25.h sockaddr.h lapb.h slip.h slhc.h ip.h internet.h tcp.h ip.h kiss.h ec.h arp.h trace.h pktdrvr.h config.h devparam.h
--- 245,251 ----
nrhdr.obj: nrhdr.c global.h mbuf.h ax25.h iface.h proc.h timer.h sockaddr.h lapb.h netrom.h nr4.h
nrs.obj: nrs.c global.h mbuf.h iface.h proc.h timer.h pktdrvr.h ax25.h sockaddr.h lapb.h nrs.h asy.h trace.h commands.h
pathname.obj: pathname.c global.h dirutil.h
! pc.obj: pc.c global.h mbuf.h proc.h timer.h iface.h internet.h session.h hardware.h ftpcli.h ftp.h telnet.h socket.h sockaddr.h cmdparse.h pc.h config.h
pc100.obj: pc100.c global.h mbuf.h iface.h proc.h timer.h pktdrvr.h netuser.h pc100.h 8530.h ax25.h sockaddr.h lapb.h trace.h pc.h session.h hardware.h ftpcli.h ftp.h telnet.h
pi.obj: pi.c global.h mbuf.h iface.h proc.h timer.h pktdrvr.h netuser.h pi.h 8530.h ax25.h sockaddr.h lapb.h trace.h pc.h session.h hardware.h ftpcli.h ftp.h telnet.h ip.h internet.h devparam.h
pktdrvr.obj: pktdrvr.c global.h proc.h mbuf.h timer.h netuser.h enet.h iface.h arcnet.h ax25.h sockaddr.h lapb.h slip.h slhc.h ip.h internet.h tcp.h ip.h kiss.h ec.h arp.h trace.h pktdrvr.h config.h devparam.h
***************
*** 293,296 ****
--- 297,315 ----
udphdr.obj: udphdr.c global.h mbuf.h ip.h iface.h proc.h timer.h internet.h udp.h netuser.h
version.obj: version.c
wildmat.obj: wildmat.c global.h
+ ntp_config.obj: ntp_config.c global.h socket.h timer.h sockaddr.h ntp_types.h ntp_syslog.h ntp_fp.h ntp.h netuser.h udp.h iface.h internet.h ip.h
+ ntp_io.obj: ntp_io.c global.h mbuf.h iface.h netuser.h socket.h proc.h timer.h sockaddr.h udp.h internet.h ip.h ntp_types.h ntp_syslog.h ntp_fp.h ntp.h
+ ntp_leap.obj: ntp_leap.c global.h timer.h sockaddr.h ntp_types.h ntp_syslog.h ntp_fp.h ntp.h netuser.h udp.h iface.h internet.h ip.h
+ ntp_loopfilter.obj: ntp_loopfilter.c global.h sockaddr.h ntp_types.h ntp_syslog.h ntp_fp.h ntp.h netuser.h udp.h iface.h internet.h ip.h
+ ntp_pcclock.obj: ntp_pcclock.c global.h sockaddr.h timer.h ntp_types.h ntp_syslog.h ntp_fp.h
+ ntp_peer.obj: ntp_peer.c global.h sockaddr.h ntp_types.h ntp_syslog.h ntp_fp.h ntp.h netuser.h udp.h iface.h internet.h ip.h
+ ntp_proto.obj: ntp_proto.c global.h timer.h sockaddr.h ntp_types.h ntp_syslog.h ntp_fp.h ntp.h netuser.h udp.h iface.h internet.h ip.h
+ ntp_restrict.obj: ntp_restrict.c global.h sockaddr.h ntp_types.h ntp_syslog.h ntp_fp.h ntp.h netuser.h udp.h iface.h internet.h ip.h
+ ntp_timer.obj: ntp_timer.c global.h timer.h sockaddr.h ntp_types.h ntp_syslog.h ntp_fp.h ntp.h netuser.h udp.h iface.h internet.h ip.h
+ ntp_util.obj: ntp_util.c global.h sockaddr.h ntp_types.h ntp_syslog.h ntp_fp.h ntp.h netuser.h udp.h iface.h internet.h ip.h
+ ntpd.obj: ntpd.c global.h sockaddr.h ntp_types.h ntp_syslog.h ntp_fp.h ntp.h netuser.h udp.h iface.h internet.h ip.h
+ ntp_version.obj: ntp_version.c
+ ntp_control.obj: ntp_control.c ntp_control.h ntp_types.h ntp_syslog.h ntp_fp.h ntp.h
+ ntp_pc.obj: ntp_pc.asm
+
*** /tmp/,RCSt1016631 Tue Jun 25 11:11:04 1991
--- pc.c Tue Jun 25 10:42:40 1991
***************
*** 1,6 ****
--- 1,7 ----
/* OS- and machine-dependent stuff for IBM-PC running MS-DOS and Turbo-C
* Copyright 1991 Phil Karn, KA9Q
*/
+
#include <stdio.h>
#include <conio.h>
#include <dir.h>
***************
*** 13,19 ****
--- 14,22 ----
#include <alloc.h>
#include <stdarg.h>
#include <bios.h>
+ #include <time.h>
#include "global.h"
+ #include "config.h"
#include "mbuf.h"
#include "proc.h"
#include "iface.h"
***************
*** 23,28 ****
--- 26,39 ----
#include "cmdparse.h"
#include "pc.h"
+ #ifdef NTP
+ #include "ntp_types.h"
+ #include "ntp_fp.h"
+
+ /* New time keeping added for NTP. */
+ l_fp NClock;
+ #endif /* NTP */
+
#define CTLC 0x3
#define DEL 0x7f
***************
*** 32,39 ****
FILE *Rawterm;
unsigned _stklen = 8192;
int Tick;
static int32 Starttime;
! int32 Clock;
/* This flag is set by setirq() if IRQ 8-15 is used, indicating
* that the machine is a PC/AT with a second 8259 interrupt controller.
--- 43,51 ----
FILE *Rawterm;
unsigned _stklen = 8192;
int Tick;
+ int SavedTick; /* timerproc puts the value of Tick here. */
static int32 Starttime;
! int32 Clock; /* Ticks since NOS started */
/* This flag is set by setirq() if IRQ 8-15 is used, indicating
* that the machine is a PC/AT with a second 8259 interrupt controller.
***************
*** 86,91 ****
--- 98,114 ----
/* Link timer handler into timer interrupt chain */
chtimer(btick);
+ #ifdef NTP
+ /* Initialize the NTP clock from DOS. */
+ #define JAN_1970 2208988800L /* 1970 - 1900 in seconds */
+ { time_t t;
+ (void) time (&t);
+ NClock.l_ui = (unsigned long)t;
+ NClock.l_ui += JAN_1970;
+ NClock.l_uf = 0;
+ }
+ #endif /* NTP */
+
/* Find out what multitasker we're running under, if any */
chktasker();
***************
*** 287,292 ****
--- 310,597 ----
Tick++;
psignal(&Tick,1);
}
+
+
+ #ifdef NTP
+ /* This should really be in the NTP source files, but it depends on the
+ * hardware.
+ */
+
+ /* Variables for adjtime(). In NTP timestamp fractional units. */
+ /* xntp recommends 500/hz as tickadj (in microseconds). For the PC,
+ * this is 27.5 usec. Converting microseconds to NTP fractions we get:
+ */
+ int32 tickadj = 0x0001ccbfL;
+ /* Storing adjust_time as a signed long in units of NTP fractions limits
+ * us to a max of +- 1/2 second adjustment at any time.
+ */
+ int32 adjust_time = 0;
+ /* Size of PC tick in ntp fractional units. */
+ int32 ntp_tick = 0x0e0f9776L;
+
+ #if 0 /* Now in ntp_pc.asm */
+ /* Called from the timer process on every tick. timerproc() saves the value
+ * of Tick in SavedTick, which is used here to make sure that we don't
+ * lose time if several timer interrupts occur before any are serviced.
+ */
+ void
+ ntppctick()
+ {
+ int32 adjust;
+
+ /* Keep the old style clock going as well. Note that the old
+ * clock will not be corrected by any adjtime() calls. */
+ Clock += SavedTick;
+
+ for (; SavedTick; SavedTick--) {
+ adjust = 0;
+ if (adjust_time) {
+ if (adjust_time < 0)
+ adjust = max(-tickadj, adjust_time);
+ else
+ adjust = min(tickadj, adjust_time);
+ adjust_time -= adjust;
+ }
+
+ /* assert ((NTP_TICK + tickadj < 2**32) &&
+ * (NTP_TICK - tickadj > 0))
+ * so that adjust will not wrap around or be negative.
+ */
+ adjust += ntp_tick;
+ /* Add in the adjustment. adjust > 0 at this point. */
+ /* I should rewrite this in assembler... */
+ L_ADDUF (&NClock, (unsigned long)adjust);
+ }
+ }
+ #endif /* 0 */
+
+ /* Return tickadj in NTP fractional units. */
+ unsigned long
+ get_tickadj()
+ {
+ return (unsigned long)tickadj;
+ }
+
+ /* Return size of a clock tick in NTP fractional units. */
+ unsigned long
+ get_tick()
+ {
+ return ntp_tick;
+ }
+
+ /* adjtime takes an NTP fraction to be adjusted, and returns any
+ * previous adjustment that hadn't completed.
+ */
+ int32
+ adjtime (frac)
+ int32 frac;
+ {
+ int32 old = adjust_time;
+ adjust_time = frac;
+ return old;
+ }
+
+ /* Tables for converting from "microticks" to NTP timestamps. */
+ unsigned long uticktotslo[256] = {
+ 0x00000000, 0x00000e10, 0x00001c1f, 0x00002a2f,
+ 0x0000383e, 0x0000464e, 0x0000545e, 0x0000626d,
+ 0x0000707d, 0x00007e8c, 0x00008c9c, 0x00009aac,
+ 0x0000a8bb, 0x0000b6cb, 0x0000c4da, 0x0000d2ea,
+ 0x0000e0f9, 0x0000ef09, 0x0000fd19, 0x00010b28,
+ 0x00011938, 0x00012747, 0x00013557, 0x00014367,
+ 0x00015176, 0x00015f86, 0x00016d95, 0x00017ba5,
+ 0x000189b5, 0x000197c4, 0x0001a5d4, 0x0001b3e3,
+ 0x0001c1f3, 0x0001d003, 0x0001de12, 0x0001ec22,
+ 0x0001fa31, 0x00020841, 0x00021650, 0x00022460,
+ 0x00023270, 0x0002407f, 0x00024e8f, 0x00025c9e,
+ 0x00026aae, 0x000278be, 0x000286cd, 0x000294dd,
+ 0x0002a2ec, 0x0002b0fc, 0x0002bf0c, 0x0002cd1b,
+ 0x0002db2b, 0x0002e93a, 0x0002f74a, 0x0003055a,
+ 0x00031369, 0x00032179, 0x00032f88, 0x00033d98,
+ 0x00034ba7, 0x000359b7, 0x000367c7, 0x000375d6,
+ 0x000383e6, 0x000391f5, 0x0003a005, 0x0003ae15,
+ 0x0003bc24, 0x0003ca34, 0x0003d843, 0x0003e653,
+ 0x0003f463, 0x00040272, 0x00041082, 0x00041e91,
+ 0x00042ca1, 0x00043ab1, 0x000448c0, 0x000456d0,
+ 0x000464df, 0x000472ef, 0x000480ff, 0x00048f0e,
+ 0x00049d1e, 0x0004ab2d, 0x0004b93d, 0x0004c74c,
+ 0x0004d55c, 0x0004e36c, 0x0004f17b, 0x0004ff8b,
+ 0x00050d9a, 0x00051baa, 0x000529ba, 0x000537c9,
+ 0x000545d9, 0x000553e8, 0x000561f8, 0x00057008,
+ 0x00057e17, 0x00058c27, 0x00059a36, 0x0005a846,
+ 0x0005b656, 0x0005c465, 0x0005d275, 0x0005e084,
+ 0x0005ee94, 0x0005fca3, 0x00060ab3, 0x000618c3,
+ 0x000626d2, 0x000634e2, 0x000642f1, 0x00065101,
+ 0x00065f11, 0x00066d20, 0x00067b30, 0x0006893f,
+ 0x0006974f, 0x0006a55f, 0x0006b36e, 0x0006c17e,
+ 0x0006cf8d, 0x0006dd9d, 0x0006ebad, 0x0006f9bc,
+ 0x000707cc, 0x000715db, 0x000723eb, 0x000731fb,
+ 0x0007400a, 0x00074e1a, 0x00075c29, 0x00076a39,
+ 0x00077848, 0x00078658, 0x00079468, 0x0007a277,
+ 0x0007b087, 0x0007be96, 0x0007cca6, 0x0007dab6,
+ 0x0007e8c5, 0x0007f6d5, 0x000804e4, 0x000812f4,
+ 0x00082104, 0x00082f13, 0x00083d23, 0x00084b32,
+ 0x00085942, 0x00086752, 0x00087561, 0x00088371,
+ 0x00089180, 0x00089f90, 0x0008ad9f, 0x0008bbaf,
+ 0x0008c9bf, 0x0008d7ce, 0x0008e5de, 0x0008f3ed,
+ 0x000901fd, 0x0009100d, 0x00091e1c, 0x00092c2c,
+ 0x00093a3b, 0x0009484b, 0x0009565b, 0x0009646a,
+ 0x0009727a, 0x00098089, 0x00098e99, 0x00099ca9,
+ 0x0009aab8, 0x0009b8c8, 0x0009c6d7, 0x0009d4e7,
+ 0x0009e2f6, 0x0009f106, 0x0009ff16, 0x000a0d25,
+ 0x000a1b35, 0x000a2944, 0x000a3754, 0x000a4564,
+ 0x000a5373, 0x000a6183, 0x000a6f92, 0x000a7da2,
+ 0x000a8bb2, 0x000a99c1, 0x000aa7d1, 0x000ab5e0,
+ 0x000ac3f0, 0x000ad200, 0x000ae00f, 0x000aee1f,
+ 0x000afc2e, 0x000b0a3e, 0x000b184e, 0x000b265d,
+ 0x000b346d, 0x000b427c, 0x000b508c, 0x000b5e9b,
+ 0x000b6cab, 0x000b7abb, 0x000b88ca, 0x000b96da,
+ 0x000ba4e9, 0x000bb2f9, 0x000bc109, 0x000bcf18,
+ 0x000bdd28, 0x000beb37, 0x000bf947, 0x000c0757,
+ 0x000c1566, 0x000c2376, 0x000c3185, 0x000c3f95,
+ 0x000c4da5, 0x000c5bb4, 0x000c69c4, 0x000c77d3,
+ 0x000c85e3, 0x000c93f2, 0x000ca202, 0x000cb012,
+ 0x000cbe21, 0x000ccc31, 0x000cda40, 0x000ce850,
+ 0x000cf660, 0x000d046f, 0x000d127f, 0x000d208e,
+ 0x000d2e9e, 0x000d3cae, 0x000d4abd, 0x000d58cd,
+ 0x000d66dc, 0x000d74ec, 0x000d82fc, 0x000d910b,
+ 0x000d9f1b, 0x000dad2a, 0x000dbb3a, 0x000dc94a,
+ 0x000dd759, 0x000de569, 0x000df378, 0x000e0188
+ };
+
+ unsigned long uticktotshi[256] = {
+ 0x00000000, 0x000e0f97, 0x001c1f2f, 0x002a2ec6,
+ 0x00383e5e, 0x00464df5, 0x00545d8d, 0x00626d24,
+ 0x00707cbc, 0x007e8c53, 0x008c9beb, 0x009aab82,
+ 0x00a8bb1a, 0x00b6cab1, 0x00c4da48, 0x00d2e9e0,
+ 0x00e0f977, 0x00ef090f, 0x00fd18a6, 0x010b283e,
+ 0x011937d5, 0x0127476d, 0x01355704, 0x0143669c,
+ 0x01517633, 0x015f85ca, 0x016d9562, 0x017ba4f9,
+ 0x0189b491, 0x0197c428, 0x01a5d3c0, 0x01b3e357,
+ 0x01c1f2ef, 0x01d00286, 0x01de121e, 0x01ec21b5,
+ 0x01fa314d, 0x020840e4, 0x0216507b, 0x02246013,
+ 0x02326faa, 0x02407f42, 0x024e8ed9, 0x025c9e71,
+ 0x026aae08, 0x0278bda0, 0x0286cd37, 0x0294dccf,
+ 0x02a2ec66, 0x02b0fbfe, 0x02bf0b95, 0x02cd1b2c,
+ 0x02db2ac4, 0x02e93a5b, 0x02f749f3, 0x0305598a,
+ 0x03136922, 0x032178b9, 0x032f8851, 0x033d97e8,
+ 0x034ba780, 0x0359b717, 0x0367c6ae, 0x0375d646,
+ 0x0383e5dd, 0x0391f575, 0x03a0050c, 0x03ae14a4,
+ 0x03bc243b, 0x03ca33d3, 0x03d8436a, 0x03e65302,
+ 0x03f46299, 0x04027231, 0x041081c8, 0x041e915f,
+ 0x042ca0f7, 0x043ab08e, 0x0448c026, 0x0456cfbd,
+ 0x0464df55, 0x0472eeec, 0x0480fe84, 0x048f0e1b,
+ 0x049d1db3, 0x04ab2d4a, 0x04b93ce2, 0x04c74c79,
+ 0x04d55c10, 0x04e36ba8, 0x04f17b3f, 0x04ff8ad7,
+ 0x050d9a6e, 0x051baa06, 0x0529b99d, 0x0537c935,
+ 0x0545d8cc, 0x0553e864, 0x0561f7fb, 0x05700792,
+ 0x057e172a, 0x058c26c1, 0x059a3659, 0x05a845f0,
+ 0x05b65588, 0x05c4651f, 0x05d274b7, 0x05e0844e,
+ 0x05ee93e6, 0x05fca37d, 0x060ab315, 0x0618c2ac,
+ 0x0626d243, 0x0634e1db, 0x0642f172, 0x0651010a,
+ 0x065f10a1, 0x066d2039, 0x067b2fd0, 0x06893f68,
+ 0x06974eff, 0x06a55e97, 0x06b36e2e, 0x06c17dc6,
+ 0x06cf8d5d, 0x06dd9cf4, 0x06ebac8c, 0x06f9bc23,
+ 0x0707cbbb, 0x0715db52, 0x0723eaea, 0x0731fa81,
+ 0x07400a19, 0x074e19b0, 0x075c2948, 0x076a38df,
+ 0x07784876, 0x0786580e, 0x079467a5, 0x07a2773d,
+ 0x07b086d4, 0x07be966c, 0x07cca603, 0x07dab59b,
+ 0x07e8c532, 0x07f6d4ca, 0x0804e461, 0x0812f3f9,
+ 0x08210390, 0x082f1327, 0x083d22bf, 0x084b3256,
+ 0x085941ee, 0x08675185, 0x0875611d, 0x088370b4,
+ 0x0891804c, 0x089f8fe3, 0x08ad9f7b, 0x08bbaf12,
+ 0x08c9beaa, 0x08d7ce41, 0x08e5ddd8, 0x08f3ed70,
+ 0x0901fd07, 0x09100c9f, 0x091e1c36, 0x092c2bce,
+ 0x093a3b65, 0x09484afd, 0x09565a94, 0x09646a2c,
+ 0x097279c3, 0x0980895a, 0x098e98f2, 0x099ca889,
+ 0x09aab821, 0x09b8c7b8, 0x09c6d750, 0x09d4e6e7,
+ 0x09e2f67f, 0x09f10616, 0x09ff15ae, 0x0a0d2545,
+ 0x0a1b34dd, 0x0a294474, 0x0a37540b, 0x0a4563a3,
+ 0x0a53733a, 0x0a6182d2, 0x0a6f9269, 0x0a7da201,
+ 0x0a8bb198, 0x0a99c130, 0x0aa7d0c7, 0x0ab5e05f,
+ 0x0ac3eff6, 0x0ad1ff8e, 0x0ae00f25, 0x0aee1ebc,
+ 0x0afc2e54, 0x0b0a3deb, 0x0b184d83, 0x0b265d1a,
+ 0x0b346cb2, 0x0b427c49, 0x0b508be1, 0x0b5e9b78,
+ 0x0b6cab10, 0x0b7abaa7, 0x0b88ca3e, 0x0b96d9d6,
+ 0x0ba4e96d, 0x0bb2f905, 0x0bc1089c, 0x0bcf1834,
+ 0x0bdd27cb, 0x0beb3763, 0x0bf946fa, 0x0c075692,
+ 0x0c156629, 0x0c2375c1, 0x0c318558, 0x0c3f94ef,
+ 0x0c4da487, 0x0c5bb41e, 0x0c69c3b6, 0x0c77d34d,
+ 0x0c85e2e5, 0x0c93f27c, 0x0ca20214, 0x0cb011ab,
+ 0x0cbe2143, 0x0ccc30da, 0x0cda4072, 0x0ce85009,
+ 0x0cf65fa0, 0x0d046f38, 0x0d127ecf, 0x0d208e67,
+ 0x0d2e9dfe, 0x0d3cad96, 0x0d4abd2d, 0x0d58ccc5,
+ 0x0d66dc5c, 0x0d74ebf4, 0x0d82fb8b, 0x0d910b22,
+ 0x0d9f1aba, 0x0dad2a51, 0x0dbb39e9, 0x0dc94980,
+ 0x0dd75918, 0x0de568af, 0x0df37847, 0x0e0187de
+ };
+
+ #if 0 /* Now in ntp_pc.asm */
+ /* getntptimeofday: Returns the current time as an NTP timestamp. */
+ void
+ getntptimeofday (ts)
+ l_fp *ts; /* return value */
+ {
+ /* Copied and adapted from msclock() */
+ int32 hi;
+ int16 lo;
+ int ticks;
+ int32 bits;
+
+ if(!Isat) {
+ *ts = NClock;
+ return;
+ }
+
+ /* Make sure that a clock tick doesn't happen while we're
+ * grabbing the clock bits.
+ */
+ do {
+ hi = Clock + Tick + SavedTick;
+ *ts = NClock;
+ bits = clockbits();
+ lo = bits;
+ ticks = Tick + SavedTick + (bits >> 16);
+ } while(hi != Clock + Tick + SavedTick);
+
+ lo = -lo; /* lo counts *down* */
+ /* Convert to NTP fractional unit by table lookup. */
+ hi = uticktotslo[lo & 0xff];
+ hi += uticktotshi[lo >> 8];
+ /* Again, I should maybe write this in assembler... */
+ L_ADDUF (ts, hi);
+
+ /* Adjust the time stamp as best I can for any yet-unprocessed
+ * clock ticks by adding in the nominal tick value.
+ */
+ while (ticks--) {
+ L_ADDUF (ts, (unsigned long)ntp_tick);
+ }
+ }
+ #endif /* 0 */
+
+ /* Step the time by ts. */
+ void
+ stepntptime (ts)
+ l_fp *ts;
+ {
+ /* Don't have to disable interrupts here since NClock is not
+ * mucked with at interrupt level.
+ */
+ L_ADD(&NClock, ts);
+ }
+
+ /* Function to set DOS time to NTP time. Called on exit
+ * (and maybe hourly as well)
+ */
+ void
+ setdostime()
+ {
+ time_t t = (time_t)(NClock.l_ui - JAN_1970);
+ stime (&t);
+ }
+
+ #else /* not NTP */
/* Called from the timer process on every tick. NOTE! This function
* can NOT be called at interrupt time because it calls the BIOS
*/
***************
*** 305,310 ****
--- 610,616 ----
oldt = t;
Clock = (days * 0x1800b0) + t - Starttime;
}
+ #endif /* not NTP */
/* Set bit(s) in I/O port */
void
***************
*** 551,558 ****
int32
msclock()
{
! int32 hi;
! int16 lo;
int16 count[4]; /* extended (48-bit) counter of timer clocks */
if(!Isat)
--- 857,864 ----
int32
msclock()
{
! int32 hi, bits;
! int16 lo, ticks;
int16 count[4]; /* extended (48-bit) counter of timer clocks */
if(!Isat)
***************
*** 559,568 ****
return Clock * MSPTICK;
do {
! hi = Clock + Tick;
! lo = clockbits();
! } while(hi != Clock + Tick);
count[0] = 0;
count[1] = hi >> 16;
count[2] = hi;
--- 865,878 ----
return Clock * MSPTICK;
do {
! hi = Clock + Tick + SavedTick;
! bits = clockbits();
! lo = bits & 0xffff;
! ticks = bits >> 16;
! } while(hi != Clock + Tick + SavedTick);
+ hi += ticks;
+
count[0] = 0;
count[1] = hi >> 16;
count[2] = hi;
***************
*** 575,582 ****
int32
secclock()
{
! int32 hi;
! int16 lo;
int16 count[4]; /* extended (48-bit) counter of timer clocks */
if(!Isat)
--- 885,892 ----
int32
secclock()
{
! int32 hi, bits;
! int16 lo, ticks;
int16 count[4]; /* extended (48-bit) counter of timer clocks */
if(!Isat)
***************
*** 583,591 ****
return (Clock * MSPTICK) / 1000L;
do {
! hi = Clock + Tick;
! lo = clockbits();
! } while(hi != Clock + Tick);
count[0] = 0;
count[1] = hi >> 16;
--- 893,905 ----
return (Clock * MSPTICK) / 1000L;
do {
! hi = Clock + Tick + SavedTick;
! bits = clockbits();
! lo = bits & 0xffff;
! ticks = bits >> 16;
! } while(hi != Clock + Tick + SavedTick);
!
! hi += ticks;
count[0] = 0;
count[1] = hi >> 16;
*** /tmp/,RCSt1016643 Tue Jun 25 11:11:09 1991
--- pc.h Tue Jun 25 10:42:42 1991
***************
*** 70,76 ****
int16 longmul __ARGS((int16 multiplier,int n,int16 *multiplicand));
INTERRUPT nullvec __ARGS((void));
void uchtimer __ARGS((void));
! int16 clockbits __ARGS((void));
/* In stopwatch.asm: */
void swstart __ARGS((void));
--- 70,79 ----
int16 longmul __ARGS((int16 multiplier,int n,int16 *multiplicand));
INTERRUPT nullvec __ARGS((void));
void uchtimer __ARGS((void));
! int32 clockbits __ARGS((void));
!
! /* In ntp_pc.asm: */
! void ntppctick __ARGS((void));
/* In stopwatch.asm: */
void swstart __ARGS((void));
*** /tmp/,RCSt1016648 Tue Jun 25 11:11:11 1991
--- pc.tl Tue Jun 25 10:42:43 1991
***************
*** 26,30 ****
+pivec.obj &
+pcgen.obj &
+sw.obj &
! +stopwatch.obj
--- 26,31 ----
+pivec.obj &
+pcgen.obj &
+sw.obj &
! +stopwatch.obj &
! +ntp_pc.obj
*** /tmp/,RCSt1016653 Tue Jun 25 11:11:13 1991
--- pcgen.asm Tue Jun 25 10:42:48 1991
***************
*** 197,208 ****
; the 8253 in the PC/XT lacks a command to read the OUTPUT pin...
;
; The PC's clock design is soooo brain damaged...
!
public clockbits
clockbits proc
! mov al,0c2h ; latch timer 0 count and status for reading
pushf
cli ; make chip references atomic
out 43h,al ; send latch command
in al,40h ; get status of timer 0
mov bl,al ; save status
--- 197,225 ----
; the 8253 in the PC/XT lacks a command to read the OUTPUT pin...
;
; The PC's clock design is soooo brain damaged...
! ;
! ; Clockbits is now defined to return a long, with the number of
! ; unhandled clock interrupts in the high word. The pc can't really
! ; count unhandled interrupts, but we can check to see if there is a
! ; clock interrupt pending (which could be the case if interrupts are turned
! ; off), and return a 1 in the high word if this is the case. We
! ; read the interrupt request register before and after reading the clock
! ; to make sure that the clock doesn't wrap around while we're reading
! ; it.
public clockbits
clockbits proc
! mov al,0ah ; 0ah tells 8259 to read the interrupt request reg.
pushf
cli ; make chip references atomic
+ out 20h,al ; Request to read interrupt request register
+ nop ; settling delay
+ nop ; (eoi does this, so me too)
+ nop
+ in al,20h ; Actually get the IRR
+ @@1:
+ mov dl,al ; save the IRR
+ and dl,1 ; Only care about bit zero.
+ mov al,0c2h ; latch timer 0 count and status for reading
out 43h,al ; send latch command
in al,40h ; get status of timer 0
mov bl,al ; save status
***************
*** 209,215 ****
--- 226,244 ----
in al,40h ; get lsb of count
mov ah,al ; save lsb
in al,40h ; get msb of count
+ mov cx,ax ; Save the count since we'll need it later.
+ mov al,0ah ; Now read the IRR again.
+ out 20h,al
+ nop
+ nop
+ nop
+ in al,20h
+ and al,1 ; only care about bit 0
+ cmp al,dl ; Is the IRR the same as the first time around?
+ jne @@1 ; nope
popf ; no more chip references
+ mov dh,0 ; Clear any garbage in the high byte of dx
+ mov ax,cx ; get the count back from storage
and bl,80h ; we're only interested in the OUT bit
xchg ah,al ; ax = count in correct order
shr ax,1 ; count /= 2
*** /tmp/,RCSt1016658 Tue Jun 25 11:11:15 1991
--- timer.c Tue Jun 25 10:42:50 1991
***************
*** 34,39 ****
--- 34,40 ----
i_state = dirps(); /* Tick is modified by an interrupt */
while(Tick == 0)
pwait(&Tick);
+ SavedTick = Tick;
Tick = 0;
restore(i_state);
*** /tmp/,RCSt1016665 Tue Jun 25 11:11:17 1991
--- timer.h Tue Jun 25 10:42:52 1991
***************
*** 39,44 ****
--- 39,45 ----
#define run_timer(t) ((t)->state == TIMER_RUN)
extern int Tick;
+ extern int SavedTick;
extern void (*Cfunc[])(); /* List of clock tick functions */
/* In timer.c: */
***************
*** 53,57 ****
--- 54,62 ----
/* In hardware.c: */
int32 msclock __ARGS((void));
int32 secclock __ARGS((void));
+ unsigned long get_tickadj();
+ unsigned long get_tick();
+ int32 adjtime __ARGS((int32));
+ void setdostime();
#endif /* _TIMER_H */